package com.zzh.lib.core.model;


import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by ZZH on 2023/2/1.
 *
 * @date: 2023/2/1 22:02
 * @email: zzh_hz@126.com
 * @author: zzh 文件
 * @description: com.zzh.lib.core.model
 */
public class HFileModel implements Parcelable {
    private long id;
    private String name;
    private String path;
    private long size;   //byte
    private String bucketId;  //Directory ID
    private String bucketName;  //Directory Name
    private long date;  //Added Date
    private boolean isSelected;
    private String mimeType;

    private boolean favorite;

    public boolean isFavorite() {
        return favorite;
    }

    public HFileModel setFavorite(boolean favorite) {
        this.favorite = favorite;
        return this;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name == null ? "" : name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path == null ? "" : path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public String getBucketId() {
        return bucketId == null ? "" : bucketId;
    }

    public void setBucketId(String bucketId) {
        this.bucketId = bucketId;
    }

    public String getBucketName() {
        return bucketName == null ? "" : bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public long getDate() {
        return date;
    }

    public void setDate(long date) {
        this.date = date;
    }

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    public String getMimeType() {
        return mimeType == null ? "" : mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public HFileModel() {
    }

    @Override
    public String toString() {
        return "HFileModel{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", path='" + path + '\'' +
                ", size=" + size +
                ", bucketId='" + bucketId + '\'' +
                ", bucketName='" + bucketName + '\'' +
                ", date=" + date +
                ", isSelected=" + isSelected +
                ", mimeType='" + mimeType + '\'' +
                ", favorite='" + favorite + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.id);
        dest.writeString(this.name);
        dest.writeString(this.path);
        dest.writeLong(this.size);
        dest.writeString(this.bucketId);
        dest.writeString(this.bucketName);
        dest.writeLong(this.date);
        dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
        dest.writeString(this.mimeType);
        dest.writeByte(this.favorite ? (byte) 1 : (byte) 0);
    }

    public void readFromParcel(Parcel source) {
        this.id = source.readLong();
        this.name = source.readString();
        this.path = source.readString();
        this.size = source.readLong();
        this.bucketId = source.readString();
        this.bucketName = source.readString();
        this.date = source.readLong();
        this.isSelected = source.readByte() != 0;
        this.mimeType = source.readString();
        this.favorite = source.readByte() != 0;
    }

    protected HFileModel(Parcel in) {
        this.id = in.readLong();
        this.name = in.readString();
        this.path = in.readString();
        this.size = in.readLong();
        this.bucketId = in.readString();
        this.bucketName = in.readString();
        this.date = in.readLong();
        this.isSelected = in.readByte() != 0;
        this.mimeType = in.readString();
        this.favorite = in.readByte() != 0;
    }

    public static final Creator<HFileModel> CREATOR = new Creator<HFileModel>() {
        @Override
        public HFileModel createFromParcel(Parcel source) {
            return new HFileModel(source);
        }

        @Override
        public HFileModel[] newArray(int size) {
            return new HFileModel[size];
        }
    };
}
